package com.vehicle.auto.click.util;

import com.jacob.activeX.ActiveXComponent;
import com.jacob.com.Dispatch;
import com.jacob.com.Variant;
import org.apache.http.protocol.HTTP;
/* loaded from: vehicle2.jar:BOOT-INF/classes/com/vehicle/auto/click/util/JacobUiVoice.class */
public class JacobUiVoice {
    public static void main(String[] args) {
        try {
            textToSpeech("语音播放");
        } catch (Throwable th) {
            System.out.println("进入catch");
        }
        System.out.println("哈哈哈");
    }

    public static void textToSpeech(String text) {
        try {
            ActiveXComponent ax = new ActiveXComponent("Sapi.SpVoice");
            Dispatch spVoice = ax.getObject();
            ax.setProperty("Volume", new Variant(100));
            ax.setProperty("Rate", new Variant(-2));
            Dispatch.call(spVoice, "Speak", new Variant(text));
            Dispatch spFileStream = new ActiveXComponent("Sapi.SpFileStream").getObject();
            ActiveXComponent ax2 = new ActiveXComponent("Sapi.SpAudioFormat");
            Dispatch spAudioFormat = ax2.getObject();
            Dispatch.put(spAudioFormat, "Type", new Variant(22));
            Dispatch.putRef(spFileStream, "Format", spAudioFormat);
            Dispatch.call(spFileStream, "Open", new Variant("./text.wav"), new Variant(3), new Variant(true));
            Dispatch.putRef(spVoice, "AudioOutputStream", spFileStream);
            Dispatch.put(spVoice, "Volume", new Variant(100));
            Dispatch.put(spVoice, "Rate", new Variant(-2));
            Dispatch.call(spVoice, "Speak", new Variant(text));
            Dispatch.call(spFileStream, HTTP.CONN_CLOSE);
            Dispatch.putRef(spVoice, "AudioOutputStream", (Object) null);
            spAudioFormat.safeRelease();
            spFileStream.safeRelease();
            spVoice.safeRelease();
            ax2.safeRelease();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
